﻿using Newtonsoft.Json.Linq;
using Sirius.Entity;
using Sirius.Util;
using System.Net;
using System.Net.Http   .Json;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using static Sirius.Data.ApiPackManager;
using static Sirius.Log.Log;
using static Sirius.WebSocket.SiriusWebSocketClient;
namespace Sirius.OpenAPI
{
    public static class openAPI
    {

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="channel_Id">子频道ID不可为空</param>
        /// <param name="content">选填，消息内容，文本内容，支持内嵌格式</param>
        /// <param name="embed">选填，embed 消息，一种特殊的 ark，详情参考Embed消息</param>
        /// <param name="ark">选填，ark 消息</param>
        /// <param name="message_reference">选填，引用消息</param>
        /// <param name="image">选填，图片url地址，平台会转存该图片，用于下发图片消息</param>
        /// <param name="msg_id">选填，要回复的消息id(Message.id), 在 AT_CREATE_MESSAGE 事件中获取。</param>
        /// <param name="markDown">选填，markdown 消息</param>
        public static string sendMessage(string channel_Id, string? msg = null, string? embedMsg = null, string? arkMsg = null, string? message_referenceMsg = null, string? image_Url = null, string? msg_Id = null, string? event_id = null, string? markDown = null)
        {
            //POST /channels/{channel_id}/messages
            try
            {
                if (msg != "" && msg != null) 
                {
                    msg = EmojiFormat.StringToEmoji(msg);
                }
                MessageEmbed embedOBJ = null;
                MessageArk arkOBJ = null;
                MessageReference referenceOBJ = null;
                MessageMarkDown markDownOBJ = null;
                if (embedMsg != "" && embedMsg != null)
                {

                    embedOBJ = JsonSerializer.Deserialize<MessageEmbed>(embedMsg);
                }



                if (arkMsg != "" && arkMsg != null)
                    arkOBJ = JsonSerializer.Deserialize<MessageArk>(arkMsg);


                if (message_referenceMsg != "" && message_referenceMsg != null)
                    referenceOBJ = JsonSerializer.Deserialize<MessageReference>(message_referenceMsg);

                if (markDown != "" && markDown != null)
                    markDownOBJ = JsonSerializer.Deserialize<MessageMarkDown>(markDown);



                var Result = SiriusHttp.PostAsJsonAsync($"{httpUrl}/channels/{channel_Id}/messages", new
                {
                    content = msg,
                    embed = embedOBJ,
                    ark = arkOBJ,
                    message_reference = referenceOBJ,
                    image = image_Url,
                    msg_id = msg_Id,
                    event_id = event_id,
                    markdown = markDownOBJ
                }); ; ;
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("发送消息", Convert.ToString((int)Result.Result.StatusCode).Substring(0, 1).Equals("2"), new Exception(), Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                LogOpenApi("发送消息", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 获取机器人基本信息
        /// </summary>
        /// <returns></returns>
        public static string? getBotInfo()
        {
            try
            {
                //GET /users/@me
                var Result = SiriusHttp.GetAsync(httpUrl + "/users/@me");

                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取Bot信息", true, null, Result.Result + "\r\n响应内容：" + Response.Result);

                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取Bot信息", false, ex, ex.ToString());
                return null;
            }

        }

        /// <summary>
        /// 获取用户频道列表
        /// </summary>
        /// <param name="before">before 设置时， 先反序，再分页</param>
        /// <param name="after">after 和 before 同时设置时， after 参数无效</param>
        /// <param name="limit">默认 100, 最大 100</param>
        /// <returns></returns>
        public static string? getGuildList(string? before, string? after, string? limit)
        {
            try
            {
                Task<HttpResponseMessage> Result = null;
                if (before != null && before != "")
                {
                    Result = SiriusHttp.GetAsync(httpUrl + "/users/@me/guilds?before=" + before + "&limit=" + limit);
                    Result.Wait();
                }
                else if (after != null && after != "")
                {
                    Result = SiriusHttp.GetAsync(httpUrl + "/users/@me/guilds?after=" + after + "&limit=" + limit);
                    Result.Wait();
                }
                else if ((after == null || after == "") && (before == "" || before == null))
                {
                    Result = SiriusHttp.GetAsync(httpUrl + "/users/@me/guilds?limit=" + limit);
                    Result.Wait();
                }

                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                string Data = Response.Result.ToString();
                LogOpenApi("获取频道列表", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Data;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取频道列表", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 获取频道详情
        /// </summary>
        /// <param name="Guild_Id">频道ID</param>
        /// <returns></returns>
        public static string? getGuildInfo(string Guild_Id)
        {
            try
            {
                //GET /guilds/{guild_id}
                var Result = SiriusHttp.GetAsync(httpUrl + $"/guilds/{Guild_Id}");
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取频道详情", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result.ToString();
            }
            catch (Exception ex)
            {
                LogOpenApi("获取频道详情", false, ex, ex.ToString());
                return "";

            }
        }

        /// <summary>
        /// 获取指定频道下的所有子频道
        /// </summary>
        /// <param name="Guild_Id">频道ID</param>
        /// <returns></returns>
        public static string? getChannelList(string Guild_Id)
        {
            try
            {

                //GET /guilds/{guild_id}/channels
                var Result = SiriusHttp.GetAsync(httpUrl + $"/guilds/{Guild_Id}/channels");
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取子频道列表", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result.ToString();
            }
            catch (Exception ex)
            {
                LogOpenApi("获取子频道列表", false, ex, ex.ToString());
                return "";
            }
        }

        /// <summary>
        /// 在指定频道创建一个子频道
        /// </summary>
        /// <param name="guild_id">频道ID</param>
        /// <param name="name">子频道名称</param>
        /// <param name="type">子频道类型 ChannelType</param>
        /// <param name="sub_type">子频道子类型 ChannelSubType</param>
        /// <param name="position">子频道排序，必填；当子频道类型为 子频道分组（ChannelType=4）时，必须大于等于 2</param>
        /// <param name="parent_id">子频道所属分组ID</param>
        /// <param name="private_type">子频道私密类型 PrivateType</param>
        /// <param name="private_user_ids">子频道私密类型成员 ID</param>
        /// <param name="speak_permission">子频道发言权限 SpeakPermission</param>
        /// <param name="application_id">应用类型子频道应用 AppID，仅应用子频道需要该字段</param>
        /// <returns></returns>
        public static string? createChannel(string guild_id, string? name, string? type, string? sub_type, string? position, string? parent_id, string? private_type, string private_user_ids, string? speak_permission, string? application_id)
        {
            try
            {
                string[] memberArray = private_user_ids.Split(",");
                if (type == "" || type == null)
                    type = "0";

                if (sub_type == "" || sub_type == null)
                    sub_type = "0";

                if (position == "" || position == null)
                    position = "0";

                if (private_type == "" || private_type == null)
                    private_type = "0";

                if (speak_permission == "" || speak_permission == null)
                    speak_permission = "1";


                //POST /guilds/{guild_id}/channels
                Task<HttpResponseMessage> Result;
                HttpRequestMessage Request = new()
                {
                    Content = new StringContent(Create_createChannelPack(name, int.Parse(type), int.Parse(sub_type), int.Parse(position), parent_id, int.Parse(private_type), memberArray, int.Parse(speak_permission), application_id), Encoding.UTF8, "application/json"),
                    Method = HttpMethod.Post,
                    RequestUri = new Uri(httpUrl + $"/guilds/{guild_id}/channels")
                };
                Result = SiriusHttp.SendAsync(Request);
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("createChannel", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("CreateChannel", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 修改子频道信息
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="name">子频道名称</param>
        /// <param name="position">排序</param>
        /// <param name="parent_id">分组 id</param>
        /// <param name="private_type">子频道私密类型 PrivateType</param>
        /// <param name="speak_permission">子频道发言权限 SpeakPermission</param>
        public static string? setChannelInfo(string? channel_Id, string? name, string? position, string? parent_id, string? private_type, string? speak_permission)
        {
            try
            {

                if (position == "" || position == null)
                    position = "0";

                if (private_type == "" || private_type == null)
                    private_type = "0";

                if (speak_permission == "" || speak_permission == null)
                    speak_permission = "1";
                //PATCH /channels/{channel_id}
                var content = new StringContent(create_setChannelInfoPack(name, int.Parse(position), parent_id, int.Parse(private_type), int.Parse(speak_permission)), Encoding.UTF8, "application/json");
                var Result = SiriusHttp.PatchAsync(httpUrl + $"/channels/{channel_Id}", content);
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("setChannelInfo", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("setChannelInfo", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 删除子频道
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <returns></returns>
        public static bool deleteChannel(string channel_Id)
        {
            try
            {
                //DELETE /channels/{channel_id}
                var Result = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_Id}");
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("删除子频道", (int)Result.Result.StatusCode == 200, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return (int)Result.Result.StatusCode == 200;
            }
            catch (Exception ex)
            {
                LogOpenApi("删除子频道", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 获取频道身份组列表
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <returns></returns>
        public static string? getGuildRoleList(string guild_Id)
        {
            try
            {
                //GET /guilds/{guild_id}/roles
                var Result = SiriusHttp.GetAsync(httpUrl + $"/guilds/{guild_Id}/roles");
                Result.Wait();

                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取频道身份组列表", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取频道身份组列表", false, ex, ex.Message);
                return "";
            }
        }


        /// <summary>
        /// 在指定频道创建一个身份组
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <param name="name">身份组名称</param>
        /// <param name="color">身份组颜色->ARGB 的 HEX 十六进制颜色值转换后的十进制数值(非必填)</param>
        /// <param name="hoist">在成员列表中单独展示: 0-否, 1-是(非必填)</param>
        /// <returns></returns>
        public static string? createGuildRole(string guild_Id, string? name, string? color, string? hoist)
        {
            try
            {
                Console.WriteLine(guild_Id);
                if (color == "" || color == null)
                    color = "0";

                if (hoist == "" || hoist == null)
                    hoist = "0";
                //POST /guilds/{guild_id}/roles
                var Result = SiriusHttp.PostAsJsonAsync(httpUrl + $"/guilds/{guild_Id}/roles", new
                {
                    name = name,
                    color = int.Parse(color),
                    hoist = int.Parse(hoist)
                });
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("创建频道身份组", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("创建频道身份组", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 获取子频道详情
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <returns></returns>
        public static string? getChannelInfo(string? channel_Id)
        {
            try
            {
                //GET /channels/{channel_id}
                var Result = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_Id}");
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取子频道详情", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取子频道详情", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 修改指定频道下的某个身份组
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <param name="name">名称(非必填)</param>
        /// <param name="color">ARGB 的 HEX 十六进制颜色值转换后的十进制数值(非必填)</param>
        /// <param name="hoist">在成员列表中单独展示: 0-否, 1-是(非必填)</param>
        /// <returns></returns>
        public static string? setGuildRole(string guild_Id, string role_Id, string? name, string? color, string? hoist)
        {
            try
            {
                if (color == "" || color == null)
                    color = "0";

                if (hoist == "" || hoist == null)
                    hoist = "0";
                //PATCH /guilds/{guild_id}/roles/{role_id}
                var data = new StringContent(Create_setGuildRolePack(name, int.Parse(color), int.Parse(hoist)), Encoding.UTF8, "application/json");
                var Result = SiriusHttp.PatchAsync(httpUrl + $"/guilds/{guild_Id}/roles/{role_Id}", data);
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("修改频道身份组", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("修改频道身份组", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 删除指定频道的某个身份组
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <returns></returns>
        public static bool deleteGuildRole(string guild_Id, string role_Id)
        {
            try
            {
                //DELETE /guilds/{guild_id}/roles/{role_id}
                var Result = SiriusHttp.DeleteAsync(httpUrl + $"/guilds/{guild_Id}/roles/{role_Id}");
                Result.Wait();
                int stateCode = (int)Result.Result.StatusCode;
                var Response = Result.Result.Content.ReadAsStringAsync();
                LogOpenApi("删除频道身份组", stateCode == 204, new Exception(), Result.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("删除频道身份组", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 将某个人添加到身份组
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <param name="user_Id">用户ID</param>
        /// <param name="channel_Id"></param>
        /// <returns></returns>
        public static bool addRoleMember(string guild_Id, string role_Id, string user_Id, string? channel_Id)
        {
            try
            {
                //PUT / guilds /{ guild_id}/ members /{ user_id}/ roles /{ role_id}
                Task<HttpResponseMessage> Request = null;
                if (role_Id.Equals("5"))
                {
                    Request = SiriusHttp.PutAsJsonAsync(httpUrl + $"/guilds/{guild_Id}/members/{user_Id}/roles/{role_Id}", new
                    {
                        channel = JsonSerializer.Deserialize<Channel>(getChannelInfo(channel_Id))
                    });
                }
                else
                {
                    Request = SiriusHttp.PutAsync(httpUrl + $"/guilds/{guild_Id}/members/{user_Id}/roles/{role_Id}", null);
                }
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("添加身份组成员", true, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("添加身份组成员", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 将指定用户移除某个身份组
        /// </summary>
        /// <param name="guild_Id">频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <param name="user_Id">用户ID</param>
        /// <param name="channel_Id">子频道ID</param>
        /// <returns></returns>
        public static bool removeRoleMember(string guild_Id, string role_Id, string user_Id, string? channel_Id)
        {
            try
            {
                //DELETE /guilds/{guild_id}/members/{user_id}/roles/{role_id}

                Task<HttpResponseMessage> Request = null;
                if (role_Id.Equals("5"))
                {
                    Channel channel = new Channel();
                    channel.ID = channel_Id;

                    HttpRequestMessage httpRequestMessage = new()
                    {
                        Content = new StringContent("{\"channel\":{\"id\":\"" + channel_Id + "\"}}", Encoding.UTF8, "application/json"),
                        Method = HttpMethod.Delete,
                        RequestUri = new Uri(httpUrl + $"/guilds/{guild_Id}/members/{user_Id}/roles/{role_Id}"),
                    };
                    Request = SiriusHttp.SendAsync(httpRequestMessage);


                }
                else
                {
                    Request = SiriusHttp.DeleteAsync(httpUrl + $"/guilds/{guild_Id}/members/{user_Id}/roles/{role_Id}");
                }
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("移除身份组成员", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("removeRoleMember", false, ex, ex.Message);
                return false;
            }
        }


        /// <summary>
        /// 获取指定用户的子频道权限
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="user_Id">用户ID</param>
        /// <returns></returns>
        public static string get_userChannelPermissions(string channel_Id, string user_Id)
        {
            try
            {
                //GET /channels/{channel_id}/members/{user_id}/permissions
                var Result = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_Id}/members/{user_Id}/permissions");
                Result.Wait();
                var Response = Result.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取成员子频道权限", true, null, Result.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取成员子频道权限", false, ex, ex.Message);
                return "";
            }
        }


        /// <summary>
        /// 修改指定人员在指定子频道拥有的权限//非公开频道
        /// </summary>
        /// <param name="channel_Id"></param>
        /// <param name="user_Id"></param>
        /// <param name="add"></param>
        /// <param name="remove"></param>
        /// <returns></returns>
        public static bool set_userChannelPermissions(string channel_Id, string user_Id, string? add, string? remove)
        {
            try
            {
                Console.WriteLine(remove);
                //PUT /channels/{channel_id}/members/{user_id}/permissions
                Task<HttpResponseMessage> Request;
                Request = SiriusHttp.PutAsJsonAsync(httpUrl + $"/channels/{channel_Id}/members/{user_Id}/permissions", new
                {
                    add = add,
                    remove = remove
                });

                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("修改成员子频道权限", (int)Request.Result.StatusCode == 204, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("修改成员子频道权限", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 获取指定身份组在指定子频道拥有的权限
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <returns></returns>
        public static string get_ChannelRolePermissions(string channel_Id, string role_Id)
        {
            try
            {
                //GET /channels/{channel_id}/roles/{role_id}/permissions
                var Request = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_Id}/roles/{role_Id}/permissions");
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取子频道身份组权限", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取子频道身份组权限", false, ex, ex.Message);
                return "";
            }
        }


        /// <summary>
        /// 修改子频道身份组权限
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="role_Id">身份组ID</param>
        /// <param name="add">添加权限</param>
        /// <param name="remove">移除权限</param>
        /// <returns></returns>
        public static bool set_ChannelRolePermissions(string channel_Id, string role_Id, string? add, string? remove)
        {
            try
            {
                //PUT /channels/{channel_id}/roles/{role_id}/permissions
                var Request = SiriusHttp.PutAsJsonAsync(httpUrl + $"/channels/{channel_Id}/roles/{role_Id}/permissions", new
                {
                    add = add,
                    remove = remove
                });
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("修改子频道身份组权限", (int)Request.Result.StatusCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("修改子频道身份组权限", false, ex, ex.Message);
                return false;
            }
        }


        /// <summary>
        /// 获取指定消息
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="msg_Id">消息ID</param>
        /// <returns></returns>
        public static string? getMessageByMsg_Id(string channel_Id, string msg_Id)
        {
            try
            {
                //GET /channels/{channel_id}/messages/{message_id}
                var Request = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_Id}/messages/{msg_Id}");
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取指定消息", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取指定消息", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 撤回消息
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="msg_Id">消息ID</param>
        /// <param name="hide">是否隐藏撤回提示</param>
        /// <returns></returns>
        public static bool RollBack_Message(string channel_Id, string msg_Id, byte hide = 0)
        {
            try
            {
                //DELETE /channels/{channel_id}/messages/{message_id}?hidetip=false
                Task<HttpResponseMessage> Request = null;
                if (hide == 1)
                {
                    Request = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_Id}/messages/{msg_Id}?hidetip=true");
                }
                else if (hide != 1)
                {
                    Request = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_Id}/messages/{msg_Id}?hidetip=false");
                }
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("撤回指定消息", (int)Request.Result.StatusCode == 200, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 200;
            }
            catch (Exception ex)
            {
                LogOpenApi("撤回指定消息", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 创建私信对话
        /// </summary>
        /// <param name="user_Id">用户id</param>
        /// <param name="guild_Id">频道id</param>
        /// <returns></returns>
        public static string? createPrivateMessage(string user_Id, string? guild_Id)
        {
            try
            {
                //POST /users/@me/dms
                var Request = SiriusHttp.PostAsJsonAsync(httpUrl + $"/users/@me/dms", new
                {
                    recipient_id = user_Id,
                    source_guild_id = guild_Id
                });
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("创建私信会话", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("创建私信会话", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 发送私信消息
        /// </summary>
        /// <param name="guild_Id">创建私信会话获取到的guild_id</param>
        /// <param name="content">消息</param>
        /// <param name="embed">embed模板消息</param>
        /// <param name="ark">ark消息</param>
        /// <param name="message_reference">引用消息</param>
        /// <param name="image_Url">图片URL</param>
        /// <param name="msg_Id">消息ID</param>
        /// <param name="markdown">md消息</param>
        /// <returns></returns>
        public static string? send_PrivateMessage(string guild_Id, string? content, string? embed, string? ark, string? message_reference, string? image_Url, string? msg_Id, string? markdown)
        {
            try
            {
                //POST /dms/{guild_id}/messages
                if (content != "" && content != null)
                {
                    content = EmojiFormat.StringToEmoji(content);
                }
                MessageEmbed embedOBJ = null;
                MessageArk arkOBJ = null;
                MessageReference referenceOBJ = null;
                MessageMarkDown markDownOBJ = null;

                if (embed != "" && embed != null)
                    embedOBJ = JsonSerializer.Deserialize<MessageEmbed>(embed);

                if (ark != "" && ark != null)
                    arkOBJ = JsonSerializer.Deserialize<MessageArk>(ark);

                if (message_reference != "" && message_reference != null)
                    referenceOBJ = JsonSerializer.Deserialize<MessageReference>(message_reference);

                if (markdown != "" && markdown != null)
                    markDownOBJ = JsonSerializer.Deserialize<MessageMarkDown>(markdown);
                var Request = SiriusHttp.PostAsJsonAsync(httpUrl + $"/dms/{guild_Id}/messages", new
                {
                    content = content,
                    embed = embedOBJ,
                    ark = arkOBJ,
                    message_reference = referenceOBJ,
                    image = image_Url,
                    msg_id = msg_Id,
                    markdown = markDownOBJ
                });
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("发送私信消息", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                Console.WriteLine(Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("发送私信消息", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 撤回私信消息
        /// </summary>
        /// <param name="guild_id">创建的私信会话频道ID</param>
        /// <param name="message_id">消息ID</param>
        /// <param name="hide">是否隐藏撤回提示</param>
        /// <returns></returns>
        public static bool RollBack_PrivateMessage(string guild_id, string message_id, byte hide = 0)
        {
            try
            {
                //DELETE /dms/{guild_id}/messages/{message_id}?hidetip=false
                Task<HttpResponseMessage> Request = null;
                if (hide == 1)
                {
                    Request = SiriusHttp.DeleteAsync(httpUrl + $"/dms/{guild_id}/messages/{message_id}?hidetip=true");
                }
                else if (hide != 1)
                {
                    Request = SiriusHttp.DeleteAsync(httpUrl + $"/dms/{guild_id}/messages/{message_id}?hidetip=false");
                }
                Request.Wait();

                var Response = Request.Result.Content.ReadAsStringAsync();
                Console.WriteLine(Response.Result);
                LogOpenApi("撤回私信消息", (int)Request.Result.StatusCode == 200, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return (int)Request.Result.StatusCode == 200;
            }
            catch (Exception ex)
            {
                LogOpenApi("撤回私信消息", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 全体禁言
        /// </summary>
        /// <param name="guild_id">频道ID</param>
        /// <param name="mute_end_timestamp">禁言时间(时间戳)</param>
        /// <param name="mute_seconds">禁言时间(秒)</param>
        /// <returns></returns>
        /// 
        public static bool No_Speak(string guild_id, string? mute_end_timestamp, string? mute_seconds)
        {
            try
            {
                //PATCH /guilds/{guild_id}/mute
                HttpContent data = new StringContent(Create_noSpeakPack(mute_end_timestamp, mute_seconds), Encoding.UTF8, "application/json");
                var Request = SiriusHttp.PatchAsync(httpUrl + $"/guilds/{guild_id}/mute", data);
                Request.Wait();
                int stateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("全体禁言", stateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("全体禁言", false, ex, ex.Message);
                return false;
            }
        }


        /// <summary>
        /// 禁言指定人员
        /// </summary>
        /// <param name="guild_id">频道id</param>
        /// <param name="user_id">用户id</param>
        /// <param name="mute_end_timestamp">禁言时间(时间戳)</param>
        /// <param name="mute_seconds">禁言时间(秒)</param>
        /// <returns></returns>
        public static bool No_SpeakByUser(string guild_id, string user_id, string? mute_end_timestamp, string? mute_seconds)
        {
            try
            {
                //PATCH /guilds/{guild_id}/members/{user_id}/mute
                HttpContent data = new StringContent(Create_noSpeakPack(mute_end_timestamp, mute_seconds), Encoding.UTF8, "application/json");
                var Request = SiriusHttp.PatchAsync(httpUrl + $"/guilds/{guild_id}/members/{user_id}/mute", data);
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                int stateCode = (int)Request.Result.StatusCode;
                LogOpenApi("禁言指定成员", stateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("禁言指定成员", false, ex, ex.Message);
                return false;
            }
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="guild_id">频道id</param>
        /// <param name="msg_id">消息id</param>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="announces_type">公告类型</param>
        /// <param name="recommend_channels">推荐子频道详情列表</param>
        /// <returns></returns>

        public static string? create_Notice(string guild_id, string? msg_id, string? channel_id, string announces_type, string? recommend_channels)
        {
            Console.WriteLine(recommend_channels);
            try
            {
                //POST /guilds/{guild_id}/announces
                if (announces_type == null || announces_type != "")
                    announces_type = "0";

                RecommendChannel[] recommendsChannelsOBJ = null;
                if (recommend_channels != null && recommend_channels != "")
                {
                    recommendsChannelsOBJ = JsonSerializer.Deserialize<Announces>(recommend_channels).Recommend_Channels;

                }

                var Request = SiriusHttp.PostAsJsonAsync(httpUrl + $"/guilds/{guild_id}/announces", new
                {
                    message_id = msg_id,
                    channel_id = channel_id,
                    announces_type = int.Parse(announces_type),
                    recommend_channels = recommendsChannelsOBJ

                });
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("创建频道公告", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("创建频道公告", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 删除公告
        /// </summary>
        /// <param name="guild_id">频道ID</param>
        /// <param name="msg_id">消息ID</param>
        /// <returns></returns>

        public static bool delete_Notice(string guild_id, string msg_id)
        {
            try
            {
                //DELETE /guilds/{guild_id}/announces/{message_id}
                var Request = SiriusHttp.DeleteAsync(httpUrl + $"/guilds/{guild_id}/announces/{msg_id}");
                Request.Wait();
                int StateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("删除公告", StateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return StateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("delete_Notice", false, ex, ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 设置精华消息
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="msg_id">消息ID</param>
        /// <returns></returns>

        public static string? addPinsMessage(string channel_id, string msg_id)
        {
            try
            {
                //PUT /channels/{channel_id}/pins/{message_id}
                var Request = SiriusHttp.PutAsync(httpUrl + $"/channels/{channel_id}/pins/{msg_id}", null);
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("设置精华消息", true, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("设置精华消息", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 取消精华消息
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="msg_id">消息ID</param>
        /// <returns></returns>
        public static bool deletePinsMessage(string channel_id, string msg_id)
        {
            try
            {
                //DELETE /channels/{channel_id}/pins/{message_id}
                var Request = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_id}/pins/{msg_id}");
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                int StatusCode = (int)Request.Result.StatusCode;
                LogOpenApi("删除精华消息", StatusCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return StatusCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("删除精华消息", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 获取精华消息
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <returns></returns>
        public static string? getPinsMessage(string channel_id)
        {
            try
            {
                //GET /channels/{channel_id}/pins
                var Request = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_id}/pins");
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("获取精华消息", true, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取精华消息", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 获取日程列表
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="since">结束时间戳</param>
        /// <returns></returns>
        public static string? getSchedulesList(string channel_id, string since)
        {
            try
            {
                Console.WriteLine(channel_id + since);
                //GET /channels/{channel_id}/schedules
                var Request = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_id}/schedules?since=" + since);
                Request.Wait();
                Console.WriteLine((Request.Result));
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                Console.WriteLine(Response.Result);
                LogOpenApi("获取日程列表", true, null, Request.Result + "\r\n响应内容：" + Response.Result);

                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取日程列表", false, ex, ex.Message);
                return "";
            }


        }

        /// <summary>
        /// 获取日程详情
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="schedule_id">日程ID</param>
        /// <returns></returns>
        public static string? getScheduleInfo(string channel_id, string schedule_id)
        {
            try
            {
                //GET /channels/{channel_id}/schedules/{schedule_id}
                var Request = SiriusHttp.GetAsync(httpUrl + $"/channels/{channel_id}/schedules/{schedule_id}");
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("获取日程详情", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("获取日程详情", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 创建日程
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="name">日程名称</param>
        /// <param name="description">日程描述</param>
        /// <param name="start_timestamp">开始时间戳</param>
        /// <param name="end_timestamp">结束时间戳</param>
        /// <param name="jump_channel_id">开始时跳转的子频道ID</param>
        /// <param name="remind_type">类型</param>
        /// <returns></returns>
        public static string? create_Schedule(string channel_id, string name, string? description, string start_timestamp, string end_timestamp, string jump_channel_id, string? remind_type = "0")
        {
            try
            {
                Console.WriteLine(description);
                //POST /channels/{channel_id}/schedules
                Schedule schedule = JsonSerializer.Deserialize<Schedule>(Create_createSchedulesPack(name, description, start_timestamp, end_timestamp, jump_channel_id, remind_type));
                Console.WriteLine(schedule.Description);
                var Request = SiriusHttp.PostAsJsonAsync(httpUrl + $"/channels/{channel_id}/schedules", new
                {
                    schedule = schedule,
                });
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("创建日程", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;
            }
            catch (Exception ex)
            {
                LogOpenApi("创建日程", false, ex, ex.Message);
                return "";
            }
        }
        /// <summary>
        /// 修改日程
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="schedule_id">日程ID</param>
        /// <param name="name">日程名称</param>
        /// <param name="description">日程描述</param>
        /// <param name="start_timestamp">开始时间戳</param>
        /// <param name="end_timestamp">结束时间戳</param>
        /// <param name="jump_channel_id">开始时跳转子频道id</param>
        /// <param name="remind_type">类型</param>
        /// <returns></returns>
        public static string? edit_Schedule(string channel_id, string schedule_id, string name, string? description, string start_timestamp, string end_timestamp, string jump_channel_id, string? remind_type = "0")
        {
            try
            {
                //PATCH /channels/{channel_id}/schedules/{schedule_id}
                var data = new StringContent("{\"schedule\":" + Create_createSchedulesPack(name, description, start_timestamp, end_timestamp, jump_channel_id, remind_type) + "}", Encoding.UTF8, "application/json");
                var Request = SiriusHttp.PatchAsync(httpUrl + $"/channels/{channel_id}/schedules/{schedule_id}", data);
                Request.Wait();
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("修改日程", true, null, Request.Result + "\r\n响应内容：" + Response.Result);
                return Response.Result;

            }
            catch (Exception ex)
            {
                LogOpenApi("修改日程", false, ex, ex.Message);
                return "";
            }
        }
        /// <summary>
        /// 删除日程
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="schedule_id">日程ID</param>
        /// <returns></returns>
        public static bool delete_Schedule(string channel_id, string schedule_id)
        {
            try
            {
                //DELETE /channels/{channel_id}/schedules/{schedule_id}
                var Request = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_id}/schedules/{schedule_id}");
                Request.Wait();
                int StateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                LogOpenApi("删除日程", StateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return StateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("删除日程", false, ex, ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 表情表态
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="message_id">消息ID</param>
        /// <param name="type">表情类型</param>
        /// <param name="emoji_Id">表情ID</param>
        /// <returns></returns>
        public static bool sendEmoji(string channel_id, string message_id, string type, string emoji_Id)
        {
            try
            {
                if (type == "" || type == null)
                    type = "0";
                //PUT /channels/{channel_id}/messages/{message_id}/reactions/{type}/{id}
                var Request = SiriusHttp.PutAsync(httpUrl + $"/channels/{channel_id}/messages/{message_id}/reactions/{int.Parse(type)}/{emoji_Id}", null);
                Request.Wait();
                int stateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                Response.Wait();
                Console.WriteLine(Response.Result);
                LogOpenApi("表情表态", stateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("表情表态", false, ex, ex.Message);
                return false;
            }
        }

        /// <summary>
        /// 删除表情表态
        /// </summary>
        /// <param name="channel_id">子频道ID</param>
        /// <param name="message_id">消息ID</param>
        /// <param name="type">表情类型</param>
        /// <param name="emoji_Id">表情ID</param>
        /// <returns></returns>
        public static bool deleteEmoji(string channel_id, string message_id, string type, string emoji_Id)
        {
            try
            {

                //DELETE /channels/{channel_id}/messages/{message_id}/reactions/{type}/{id}
                if (type == "" || type == null)
                    type = "0";

                var Request = SiriusHttp.DeleteAsync(httpUrl + $"/channels/{channel_id}/messages/{message_id}/reactions/{int.Parse(type)}/{emoji_Id}");
                Request.Wait();
                int stateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("删除表情表态", stateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("删除表情表态", false, ex, ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 移除频道成员(仅私域可用)
        /// </summary>
        /// <param name="guild_id">频道id</param>
        /// <param name="user_id">用户id</param>
        /// <param name="add_blacklist">是否拉黑</param>
        /// <param name="delete_history_msg_days">删除成员的同时，撤回该成员的消息，可以指定撤回消息的时间范围</param>
        /// <returns>注：消息撤回时间范围仅支持固定的天数：`3`，`7`，`15`，`30`。 特殊的时间范围：`-1: 撤回全部消息`。默认值为`0`不撤回任何消息。</returns>
        public static bool removeGuildMember(string guild_id, string user_id, byte add_blacklist = 0, string delete_history_msg_days = "0")
        {
            try
            {
                //DELETE /guilds/{guild_id}/members/{user_id}
                HttpRequestMessage httpRequestMessage = null;
                JObject json = new JObject();
                if (add_blacklist == 0)
                {
                    json.Add("add_blacklist", false);
                    json.Add("delete_history_msg_days", Convert.ToInt16(delete_history_msg_days));
                    httpRequestMessage = new()
                    {
                        Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json"),
                        Method = HttpMethod.Delete,
                        RequestUri = new Uri(httpUrl + $"/guilds/{guild_id}/members/{user_id}"),
                    };

                }
                else
                {
                    json.Add("add_blacklist", true);
                    json.Add("delete_history_msg_days", Convert.ToInt16(delete_history_msg_days));
                    httpRequestMessage = new()
                    {
                        Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json"),
                        Method = HttpMethod.Delete,
                        RequestUri = new Uri(httpUrl + $"/guilds/{guild_id}/members/{user_id}"),
                    };
                }
                var Request = SiriusHttp.SendAsync(httpRequestMessage);
                Request.Wait();
                int stateCode = (int)Request.Result.StatusCode;
                var Response = Request.Result.Content.ReadAsStringAsync();
                LogOpenApi("移除频道成员", stateCode == 204, new Exception(), Request.Result + "\r\n响应内容：" + Response.Result);
                return stateCode == 204;
            }
            catch (Exception ex)
            {
                LogOpenApi("移除频道成员", false, ex, ex.Message);
                return false;
            }

        }

        /// <summary>
        /// 获取频道成员列表
        /// </summary>
        /// <param name="after">上一次回包中最后一个member的user id， 如果是第一次请求填 0，默认为 0</param>
        /// <param name="limit">分页大小，1-400，默认是 1。成员较多的频道尽量使用较大的limit值，以减少请求数</param>
        /// <returns></returns>
        public static  string getMemberList(string guild_id, string after, string limit)
        {

            //GET /guilds/{guild_id}/members
            try
            {
                var request = SiriusHttp.GetAsync(httpUrl + $"/guilds/{guild_id}/members?after={after}&limit={limit}");
                request.Wait();
                var response = request.Result.Content.ReadAsStringAsync();
                LogOpenApi("获取频道成员列表", true, null, request.Result + "\r\n响应内容：" + response.Result);
                return response.Result; 
            }
            catch (Exception ex)
            {
                LogOpenApi("获取频道成员列表", false, ex, ex.Message);
                return "";
            }
        }
        /// <summary>
        /// 获取身份组成员列表
        /// </summary>
        /// <param name="guild_id">频道id</param>
        /// <param name="role_id">身份组id</param>
        /// <param name="start_index">将上一次回包中next填入， 如果是第一次请求填 0，默认为 0</param>
        /// <param name="limit">分页大小，1-400，默认是 1。成员较多的频道尽量使用较大的limit值，以减少请求数</param>
        /// <returns></returns>
        public static string getMemberListByRole(string guild_id,string role_id, string start_index,string limit)
        {
            try
            {
                //GET /guilds/{guild_id}/roles/{role_id}/members
                var request = SiriusHttp.GetAsync(httpUrl + $"/guilds/{guild_id}/roles/{role_id}/members?start_index={start_index}&limit={limit}");
                request.Wait();
                var response = request.Result.Content.ReadAsStringAsync(); 
                string data = response.Result;
                LogOpenApi("获取身份组成员列表", true, null, request.Result + "\r\n响应内容：" + response.Result);
                return data;
            } catch(Exception ex)
            {
                LogOpenApi("获取身份组成员列表", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 获取频道成员详情
        /// </summary>
        /// <param name="guild_id">频道ID</param>
        /// <param name="user_id">用户id</param>
        /// <returns></returns>
        public static string getMemberInfo(string guild_id,string user_id)
        {
            try
            {
                //GET /guilds/{guild_id}/members/{user_id}
                var request = SiriusHttp.GetAsync(httpUrl + $"/guilds/{guild_id}/members/{user_id}");
                request.Wait();
                var response = request.Result.Content.ReadAsStringAsync();
                response.Wait();
                string data = response.Result;
                LogOpenApi("获取成员详情", true, null, request.Result + "\r\n响应内容：" + response.Result);
                return data;
            }catch(Exception ex)
            {
                LogOpenApi("获取成员详情", false, ex, ex.Message);
                return "";
            }
        }

        /// <summary>
        /// 发送图文消息
        /// </summary>
        /// <param name="channel_Id">子频道ID</param>
        /// <param name="msg">消息内容</param>
        /// <param name="msg_id">消息ID</param>
        /// <param name="imgPath">图片路径</param>
        /// <returns></returns>
        public static string sendImgMessage(string channel_Id,string msg ,string msg_id,string imgPath)
        {
            //POST /channels/{channel_id}/messages
            try
            {
                var content = new MultipartFormDataContent();

                content.Add(new StreamContent(new MemoryStream(File.ReadAllBytes(imgPath))), "file_image", "file_image");

                if (msg_id != "" && msg_id != null)
                    content.Add(new StringContent(msg_id, Encoding.UTF8), "msg_id");

                if (msg != "" && msg != null)
                    content.Add(new StringContent(msg, Encoding.UTF8), "content");

                var result = SiriusHttp.PostAsync($"{httpUrl}/channels/{channel_Id}/messages", content);
                int stateCode = (int)result.Result.StatusCode;
                result.Wait();
                var response = result.Result.Content.ReadAsStringAsync();
                response.Wait();
                LogOpenApi("发送图文消息", Convert.ToString(stateCode).Substring(0, 1).Equals("2"), new Exception(), result.Result + "\r\n响应内容：" + response.Result);
                return response.Result;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                LogOpenApi("发送图文消息", false, ex, ex.Message);
                return "";
            }
        }


    }
}